package org.example.sec04;

import com.google.protobuf.Int32Value;
import com.google.protobuf.Timestamp;
import com.seaway.models.common.Address;
import com.seaway.models.common.BodyStyle;
import com.seaway.models.common.Car;
import com.seaway.models.sec04.Person;
import com.seaway.models.sec04.Sample;

import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

public class Demo {
    public static void main(String[] args) {
        var address = Address.newBuilder()
                .setCity("a")
                .build();

        var cat = Car.newBuilder().setBodyStyle(BodyStyle.COUPE).build();
        var person= Person.newBuilder()
                .setCar(cat)
                .setAddress(address);

        var sample= Sample.newBuilder()

                .setLoginTime(Timestamp.newBuilder().setSeconds(Instant.now().getEpochSecond())).build();
        System.out.println(sample.hasAge());
        System.out.println(Instant.ofEpochSecond(sample.getLoginTime().getSeconds()).atZone(ZoneId.systemDefault()).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
        System.out.println(Instant.now().getEpochSecond());
    }
}
